'''
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with self work for additional information
 * regarding copyright ownership.  The ASF licenses self file
 * to you under the Apache License, Version 2.0 (the
 * "License") you may not use self file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http:#www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
'''
from base.graph.Node import Node
from base.java.Objects import Objects

#import java.util.Objects;

#import org.apache.jena.shared.PrefixMapping;

'''
 * RDF triples as RDF terms for RDF-star embedded triples.
'''
class Node_Triple(Node):

    #private final Triple triple

    # param Node s, Node p, Node o:
    # def __init__(self, s, p, o):
    #     self(Triple.create(s, p, o))
    

    # param Triple triple:
    def __init__(self, triple):
        super().__init__(triple)
        self.triple = triple
    

    #@Override
    # param 
    # result Triple
    def getTriple(self):
        return self.triple
    


    #@Override
    # param 
    # result boolean
    def isConcrete(self):
        return self.getTriple().isConcrete()
    

    #@Override
    # param 
    # result boolean
    def isNodeTriple(self):
        return True
    

    #@Override
    # param NodeVisitor v
    # result Object
    def visitWith(self, v):
        return v.visitTriple(self, self.triple)
    

    # Only based on label.
    #@Override
    # param 
    # result int
    def hashCode(self):
        #final int
        prime = 31
        #int
        result = super().hashCode()
        result = prime * result + Objects.hash(self.label)
        return result
    

    #@Override
    # param Object obj
    # result boolean
    def equals(self, obj):
        if (self == obj):
            return True
        if (obj is None):
            return False
        #if (getClass() != obj.getClass()):
        if (type(self).__name__ != type(obj).__name__):
            return False
        #Node_Triple other = (Node_Triple) obj
        #return Objects.equals(label, other.label)
        return Objects.equals(self.label, obj.label)
    


    #@Override
    # param PrefixMapping pm, boolean quoting
    # result String
    def toString(self):
        return "<< " + self.label.toString() + " >>"
    

